﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Security;
using System.Windows.Controls;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.IO;
using System.Web;
using System.Web.UI;

namespace PepsiCo.RBS.CustomFields
{
    public class ColorPickerField : SPFieldText
    {
        public ColorPickerField(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        {
        }
        public ColorPickerField(SPFieldCollection fields, string typeName, string displayName)
            : base(fields, typeName, displayName)
        {
        }
        public override BaseFieldControl FieldRenderingControl
        {
            [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
            get
            {
                BaseFieldControl fieldControl = new ColorPickerFieldControl();
                fieldControl.FieldName = this.InternalName;
                return fieldControl;
            }
        }
        public override string GetValidatedString(object value)
        {
            if ((this.Required == true) && ((value == null) || ((String)value == "")))
            {
                throw new SPFieldValidationException(this.Title + " must have a value.");
            }
            else
            {

                return base.GetValidatedString(value);

            }
        }
    }
}
